<template>
	<view class="container">
		<view v-for="(item,index) in items" :key="index">
			<view>
				<uni-card :title="item.title" :sub-title="item.time" :thumbnail="imgPath+img_status[item.status]" @click="cardClick(index)">
					<!-- <uni-dateformat :date="item.time" :threshold="[60000,3600000]" format="yyyy-MM-dd hh:mm:ss">
					</uni-dateformat> -->
					<view> {{ item.content }} </view>
				</uni-card>
			</view>
		</view>
		<uni-fab horizontal="right" vertical="bottom" @fabClick="onClick">
		</uni-fab>
	</view>
</template>

<script>
	import {parseTime} from "@/utils/tool.js";
	import {getTheStorage} from "@/utils/common.js"
	export default {
		data() {
			return {
				imgPath: "/static/images/",
				img_status: ["Not-started.png", "in-progress.png", "complete.png"],
				items: []
			};
		},
		onLoad() {
			this.getData()
		},
		methods:{
			cardClick(index) {
			    uni.navigateTo({
					url: "/pages/detail/detail?funcode=1&&id=" +this.items[index]._id
				})
			},

			onClick(){
				uni.navigateTo({
					url:"/pages/detail/detail?funcode=0"
				})
			},
			getData(){
			    	uniCloud.callFunction({
			    		name: "CloudGetData",
			    		data: {
			    			type:'all',   //要求返回全部备忘录
			    			id:"000"      //当type为'all'时候，id无意义
			    		}
			    	}).then(res => {
			    		console.log(res)
			    		this.items = res.result.data
			    		for (let index in this.items) {  //for循环每次获得index
			    			if (!this.items[index].time) {  //但创建时间为空时
			    				this.items[index].time = Date.now()
			    			}
			    			this.items[index].time = parseTime(this.items[index].time)
			    		}
			    	})

			}
		}
	}
</script>

<style lang="scss" scoped>
	/deep/ .uni-card .uni-card__header .uni-card__header-content .uni-card__header-content-title {
		font-size: 38rpx;
		font-weight: bold;
	}
</style>

